package cn.ai.boot.config;

/**
 * @author jie.zhao@dms365.com
 * @Date 2025/7/4 16:43
 */
public class TEst3333333 {
    private static final Object lock1 = new Object();
    private static final Object lock2 = new Object();
    public static void main(String[] args) {
        Thread threadA = new Thread(() -> {
            synchronized (lock1) {
                System.out.println("ThreadA holding lock1...");
                try { Thread.sleep(100); } catch (InterruptedException e) {}
                System.out.println("ThreadA waiting for lock2...");
                synchronized (lock2) {
                    System.out.println("ThreadA acquired both locks!");
                }
            }
        });

        Thread threadB = new Thread(() -> {
            synchronized (lock2) {
                System.out.println("ThreadB holding lock2...");
                try { Thread.sleep(100); } catch (InterruptedException e) {}
                System.out.println("ThreadB waiting for lock1...");
                synchronized (lock1) {
                    System.out.println("ThreadB acquired both locks!");
                }
            }
        });

        threadA.start();
        threadB.start();
    }
}
